package com.tmsps.ne4weixin.api;

import com.alibaba.fastjson2.JSONObject;
import com.tmsps.ne4weixin.bean.message.custom.BaseMessage;
import com.tmsps.ne4weixin.config.WxConfig;
import com.tmsps.ne4weixin.utils.WXHttpUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * @Title: CustomAPI.java
 * @Package: com.tmsps.ne4weixin.api
 * @Description: 客服消息管理API
 */
@Slf4j
public class CustomAPI extends BaseAPI {

	public CustomAPI(WxConfig config) {
		super(config);
	}
	
	
	public String sendMessage(BaseMessage message) {
		String url = String.format(SEND_MSG, wxConfig.getAccessToken());
		log.debug(JSONObject.toJSONString(message));
		return WXHttpUtil.postJson(url, JSONObject.toJSONString(message));
	}
	
	/**
	 * 发送客服消息
	 * @param json
	 * @return
	 */
	public String sendMessage(String json) {
		String url = String.format(SEND_MSG, wxConfig.getAccessToken());
		return WXHttpUtil.postJson(url, json);
	}
}
